/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package tableCellRender;

import java.awt.Color;
import java.awt.Component;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;
import otros.Util;

/**
 *
 * @author FERRETERIA
 */
public class Render_CheckBox extends JCheckBox implements TableCellRenderer {

    private JComponent component = new JCheckBox();
    private int filaSel;
    private boolean fuera;

    /** Constructor de clase */
    public Render_CheckBox(int fila, boolean fuera) {
        setOpaque(true);
        filaSel = fila;
        this.fuera = fuera;
    }

  public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      //Color de fondo de la celda
      //( (JCheckBox) component).setBackground( new Color(0,200,0) );
      component.setBackground(Util.getBackground(row,filaSel,table, isSelected, fuera));
      component.setForeground(Util.getForeground(row,filaSel,table,isSelected, fuera));          
        
      //obtiene valor boolean y coloca valor en el JCheckBox
      if (value != null) {
      boolean b = ((Boolean) value).booleanValue();
      ( (JCheckBox) component).setSelected( b );
      }
      return ( (JCheckBox) component);
  }

}
    
